package jspSamples.unit7.websiteSample;

import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.SQLException;
import java.sql.Statement;


public class News {
    DBConnection db = new DBConnection();
    Function function = new Function();
    public String ListNews() throws SQLException{
        Connection conn = db.getConn();
        Statement statement = conn.createStatement();
        String sql = "select * from news";
        ResultSet resultSet = statement.executeQuery(sql);
        StringBuffer sb = new StringBuffer();
        StringBuffer stringBuffer = function.ListNews(sb,resultSet);
        /*释放资源*/
        db.close(resultSet, statement, conn);

        return stringBuffer.toString();
    }
}

